package com.qf.springboot.demoredis.controller;

import com.qf.springboot.demoredis.service.Impl.TrainTickService;
import com.qf.springboot.demoredis.service.RedisService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

/**
 * @Auther: Adrian
 * @Date: 2020/3/9 18:47
 * @Description:
 */
@RestController
public class RedisController {
    @Autowired
    private RedisService redisService;

    @Autowired
    private TrainTickService trainTickService;
    /**
     * 添加数据
     * @return
     */
    @RequestMapping("addValue")
    public Object addValue(){
        redisService.add("movietickes","100");
        return "执行完成....";
    }

    @RequestMapping("getValue")
    public String getValue(String key){
        //Redis中有没有  跟序列化相关的类
        return redisService.getValueForKey(key);
    }

    @RequestMapping("produceStockRedisson")
    public String produceStockRedisson(){
        return trainTickService.produceStockRedisson();
    }
}
